package com.ivo.core.hibernate;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass;

/**
 * Hibernate Model的基础父类, 含ID、创建者、创建时间、最近更新者、最近更新时间、有效标识符
 *
 * @author minkey
 */
@MappedSuperclass
public class Model implements Serializable {

  /**
   *
   */
  private static final long serialVersionUID = 9098787643424546757L;

  /**
   * ID
   */
  @Id
  @GeneratedValue(strategy = GenerationType.AUTO)
  @Column(name = "ID")
  protected Long id;

  /**
   * 创建者
   */
  @Column(name = "CREATE_USER")
  protected String creator;

  /**
   * 创建时间
   */
  @Column(name = "CREATE_TIME")
  protected Date createTime = null;

  /**
   * 最近更新者
   */
  @Column(name = "UPDATE_USER")
  protected String updater;

  /**
   * 最近更新时间
   */
  @Column(name = "UPDATE_TIME")
  protected Date updateTime = null;

  /**
   * 有效标识位
   */
  @Column(name = "IS_VALID")
  protected boolean isValid = true;

  public Model() {
  }

  public Model(Long id) {
    this.id = id;
  }


  public Long getId() {
	return id;
}

public void setId(Long id) {
	this.id = id;
}

public String getCreator() {
    return creator;
  }

  public void setCreator(String creator) {
    this.creator = creator;
  }

  public Date getCreateTime() {
    return createTime;
  }

  public void setCreateTime(Date createTime) {
    this.createTime = createTime;
  }

  public String getUpdater() {
    return updater;
  }

  public void setUpdater(String updater) {
    this.updater = updater;
  }

  public Date getUpdateTime() {
    return updateTime;
  }

  public void setUpdateTime(Date updateTime) {
    this.updateTime = updateTime;
  }

  public boolean getIsValid() {
    return isValid;
  }

  public void setIsValid(boolean isValid) {
    this.isValid = isValid;
  }

  /**
   * 复写toString方法，使得在有些场合可以直接看到这个对象的一些信息
   *
   * @return String 字符串
   */
  @Override
  public String toString() {
    return super.toString() + "@" + id;
  }

}
